package tester;

import java.util.regex.*;

public class tester2 {
	
	public static void main(String[] args) {
		String aaa = "((NOT (FILE_WILDCARD:*.txt AND FILEPINES:PINES)) AND (NOT FILE_WILDCARD:*.png))";
		Pattern patt = Pattern.compile("\\(.*?\\)");
		Matcher match = patt.matcher(aaa);
		match.find();
		int i = match.start();
		int j = match.end();
		System.out.println(aaa.substring(i, j));
		
		match.reset();
		aaa = aaa.substring(i+1, j-1);
		match = patt.matcher(aaa);
		match.find();
		i = match.start();
		j = match.end();
		System.out.println(aaa.substring(i, j));

	}
}
